package org.bwgl.demo1.controller;

import org.bwgl.demo1.pojo.Person;
import org.springframework.web.bind.annotation.*;

@RestController
public class MyHello2 {
    @GetMapping(value = "hello")
//    @PostMapping
//    @PutMapping
//    @DeleteMapping
    public String hello(){
        return "hello";
    }

    @GetMapping(value = "hello1")
//    @RequestParam 的时候有没有传值都可以，加了以后就必须要有这个名字的传值
    public String hello1(String name){
        return name;
    }

    @GetMapping(value = "hello2")
    public String hello2(@RequestParam(value = "username") String name){
        return name;
    }

    @PostMapping(value = "hello3")
//    web html form
//    @RequestMapping(method = RequestMethod.POST,value = "hello3")
    public String hello3(String username,int age){
        return username + age; // "lpz" 60  int->Integer toString()->String =>   "lpz60"
    }

    @PostMapping(value = "hello4")
    public String hello4(Person p){
        return p.toString();
    }

    @PostMapping(value = "hello5")
    public String hello5(@RequestBody Person p){
        return p.toString();
    }

}
